From: Florian Müllner Date: Sat, 8 Jul 2023 11:06:05 +0000 (+0200) Subject: ci: Print eslint results to stdout as well X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~337^2~1^2~164 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=3a086c43ae1e6d73b0601f06a1fed7922cd29db4;p=gnome-shell.git ci: Print eslint results to stdout as well The eslint jobs report their results as artifacts in junit format, so that gitlab can present them in its UI. However many people miss that, and unsuccessfully check the logs instead. Account for that by also printing the results to stdout. Part-of: --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 87601aad4..22e6e815c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -142,7 +142,7 @@ eslint: stage: review script: - export NODE_PATH=$(npm root -g) - - ./.gitlab-ci/run-eslint --output-file ${LINT_LOG} --format junit + - ./.gitlab-ci/run-eslint --output-file ${LINT_LOG} --format junit --stdout artifacts: reports: junit: ${LINT_LOG} @@ -155,7 +155,7 @@ eslint_mr: stage: review script: - export NODE_PATH=$(npm root -g) - - ./.gitlab-ci/run-eslint --output-file ${LINT_MR_LOG} --format junit + - ./.gitlab-ci/run-eslint --output-file ${LINT_MR_LOG} --format junit --stdout --remote ${CI_MERGE_REQUEST_PROJECT_URL}.git --branch ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} only: diff --git a/.gitlab-ci/run-eslint b/.gitlab-ci/run-eslint index 0d9fcf456..5d0e41c8e 100755 --- a/.gitlab-ci/run-eslint +++ b/.gitlab-ci/run-eslint @@ -81,6 +81,10 @@ async function getMergeRequestChanges(remote, branch) { return report; } +function hasOption(...names) { + return process.argv.some(arg => names.includes(arg)); +} + function getOption(...names) { const optIndex = process.argv.findIndex(arg => names.includes(arg)) + 1; @@ -120,6 +124,11 @@ function getOption(...names) { if (outputPath) { fs.mkdirSync(path.dirname(outputPath), { recursive: true }); fs.writeFileSync(outputPath, resultText); + + if (hasOption('--stdout')) { + const consoleFormatter = await regular.loadFormatter(); + console.log(consoleFormatter.format(commonResults)); + } } else { console.log(resultText); }